import Vue from 'vue'
import App from './App'
import store from './store'

import './plugin/ajax'
import './plugin/modal'
import './mixin'

const msg = (title, duration = 1500, mask = false, icon = 'none') => {
	//统一提示方便全局修改
	if (Boolean(title) === false) {
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}

//获取购物车数据
const getStoreCart=(store_id,cartarray)=>{
	let ret = [];
	for(var i=0;i<cartarray.length;i++){
		if(cartarray[i].store_id==store_id){
			ret.push(cartarray[i]);
		}
	}
	return ret;
}

//设置角标
const setCartBadge=(num)=>{
	if(num>0){
		uni.setTabBarBadge({
		  index: 2,
		  text: num+''
		})
	}else{
		uni.removeTabBarBadge({index:2})
	}
}

const prePage = () => {
	let pages = getCurrentPages();
	let prePage = pages[pages.length - 2];
	// #ifdef H5
	return prePage;
	// #endif
	return prePage.$vm;
}




Vue.config.productionTip = false
Vue.prototype.$api = {
	msg,
	prePage
};
App.mpType = 'app'

// 引入全局uView
import uView from 'uview-ui'
Vue.use(uView);



const app = new Vue({
    ...App
})
app.$mount()
